package com.hotel.servlet; /**
 * Created by Enzo Cotter on 2021/5/13.
 */

import com.hotel.bean.Account;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.lang.invoke.SwitchPoint;

@WebServlet(name = "ContextServlet", value = "/ContextServlet")
public class ContextServlet extends HttpServlet {
//    内容页面Servlet
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String hotel = request.getParameter("hotel");
        Account account = (Account) request.getSession().getAttribute("curUser");
        request.setAttribute("account",account);
        switch (hotel){
            case "jianguo":
                System.out.println("1:"+account);
                request.getRequestDispatcher("/jsp/jianguoHotel.jsp").forward(request,response);
                break;
            case "bocui":
                System.out.println("2:"+account);
                request.getRequestDispatcher("/jsp/bocuiHotel.jsp").forward(request,response);
                break;
            case "jinglun":
                System.out.println("3:"+account);
                request.getRequestDispatcher("/jsp/jinglunHotel.jsp").forward(request,response);
                break;
            case "nanyuan":
                System.out.println("4:"+account);
                request.getRequestDispatcher("/jsp/nanyuanHotel.jsp").forward(request,response);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
